package com.face.server.controller;

import com.face.RespMsg;
import com.face.server.entity.GlobalConfig;
import com.face.server.repository.GlobalConfigRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 目前还不完善需要权限过滤
 */
@RestController
@RequestMapping("/config")
public class GlobalConfigController {

    @Autowired
    GlobalConfigRepository globalConfigRepository;

    @GetMapping
    RespMsg getConfig() {
        return RespMsg.build(globalConfigRepository.findBy());
    }

    @PostMapping
    RespMsg saveConfig(@RequestBody GlobalConfig config) {
        return RespMsg.build(globalConfigRepository.save(config).getId());
    }
}
